<?php
	header("Content-Type: text/html;charset=utf-8");
	include("function/_nosql.php"); //
	include("function/function.php");
	include("_include.user.judge.php");
	$kboy_userid = $_SESSION['kboy_userid'];
	$kboy_user = $_SESSION['kboy_user'];
	$aid = chkstr(trim($_REQUEST['aid']));
	$uid = chkstr(trim($_REQUEST['uid']));
	$action = chkstr(trim($_REQUEST['action']));
	$album_title = chkstr(trim($_REQUEST['album_title']));
	$album_shoottime = chkstr(trim($_REQUEST['album_shoottime']));
	$album_text = chkstr(trim($_REQUEST['album_text']));
	
	if($action == "add"){
		if(strlen($album_title)<1){
			echo erro("相册名称不能为空！");
		}
		if(strlen($album_shoottime)<1){
			echo erro("拍摄时间不能为空！");
		}

		// 添加内容
		$mysql = new sqlstr("kboy_forum_album"); 
		$mysql -> set("album_title",$album_title);
		$mysql -> set("album_shoottime",$album_shoottime);
		$mysql -> set("album_text",$album_text);
		$mysql -> set("uid",$kboy_userid);
		$news_sql = $mysql -> insertSql();
		$news_res = mysql_query($news_sql);
		if($news_res){
			echo ok("操作成功","forum_photo.php?uid=".$kboy_userid);
		}else{
			echo erro("服务器内部错误");
		}
	}elseif($action == "edit"){
		if(empty($aid)){
			echo erro("参数错误");
		}
		if(!is_numeric($aid)){
			echo erro("参数错误");
		}
		
		if(strlen($album_title)<1){
			echo erro("相册名称不能为空！");
		}
		if(strlen($album_shoottime)<1){
			echo erro("拍摄时间不能为空！");
		}

		// 添加内容
		$mysql = new sqlstr("kboy_forum_album"); 
		$mysql -> set("album_title",$album_title);
		$mysql -> set("album_shoottime",$album_shoottime);
		$mysql -> set("album_text",$album_text);
		$news_sql = $mysql -> updateSql("id=$aid and uid=$kboy_userid");
		$news_res = mysql_query($news_sql);
		if($news_res){
			echo ok("操作成功","forum_photo.php?uid=".$kboy_userid);
		}else{
			echo erro("服务器内部错误");
		}
	}elseif($action == "del"){
		if(empty($aid)){
			echo erro("参数错误");
		}
		if(!is_numeric($aid)){
			echo erro("参数错误");
		}
		

		// 删除数据
		$mysql = new sqlstr("kboy_forum_album"); 
		$news_sql = $mysql -> deleteSql("id=$aid and uid=$kboy_userid");
		$news_res = mysql_query($news_sql);
		if($news_res){
			mysql_query("delete from kboy_forum_pic where aid=$aid and uid=$kboy_userid");
			echo ok("操作成功","forum_photo.php?uid=".$kboy_userid);
		}else{
			echo erro("服务器内部错误");
		}
	}else{
		echo erro("参数错误");
	}
?>